package b2.widget
{
	import b2.util.*;
	
	import flash.display.*;
	import flash.events.*;
	import flash.ui.Mouse;

	public class ImgSwitchIcon extends Sprite
	{
		private var backgroundImage:Sprite; 
		private var mouseOverImage:Sprite;
		
		public function ImgSwitchIcon(BackgroundImage:Class, MouseOverImage:Class)
		{
			super();
			backgroundImage = new BackgroundImage();
			backgroundImage.mouseChildren = false;
			addChild(backgroundImage);
			mouseOverImage = new MouseOverImage();
			mouseOverImage.mouseChildren = false;
			mouseOverImage.visible = false;
			addChild(mouseOverImage);
			this.addEventListener(MouseEvent.MOUSE_OVER, onMouseOver);
			this.addEventListener(MouseEvent.MOUSE_OUT, onMouseOut);
		}
		
		private function onMouseOver(event:MouseEvent):void
		{
			Mouse.cursor = "button";
			backgroundImage.visible = false;
			mouseOverImage.visible = true;
		}
		
		private function onMouseOut(event:MouseEvent):void
		{
			Mouse.cursor = "auto";
			backgroundImage.visible = true;
			mouseOverImage.visible = false;
		}
	}
}